// 筛选值
export const RetrunOptions = (data: any, value: any) => {
  const {
    assistant,
    group,
    org,
    product,
  } = data

  // 品牌
  if (value == 'assistant_id' && assistant) {
    return assistant.map((item: any) => {
      return { value: item.assistant_id, label: item.assistant_name }
    })
  }
  // 客户分组
  if (value == 'group_id' && group) {
    return group.map((item: any) => {
      return { value: item.group_id, label: item.group_name }
    })
  }

  // 下单/收款组织
  if (value == 'org_id' && org) {
    return org.map((item: any) => {
      return { value: item.org_id, label: item.org_name }
    })
  }
  // 条码
  if (value == 'barcode' && product) {
    return product.map((item: any) => {
      return { value: item.barcode, label: item.barcode }
    })
  }
  // 品名
  if (value == 'name' && product) {
    return product.map((item: any) => {
      return { value: item.name, label: item.name }
    })
  }

  return []
}

export const OccupySalesOptions = (data: any, value: any) => {
  const {
    brand,
    series,
    category,
    customerList,
    productList,
  } = data

  // 品牌
  if (value == 'assistant_id' && brand) {
    return brand.map((item: any) => {
      return { value: item.entry_id, label: item.name }
    })
  }
  // 物料大类
  if (value == 'large_category_id' && category) {
    return category.map((item: any) => {
      return { value: item.id, label: item.data_title }
    })
  }
  // 系列
  if (value == 'xl_id' && series) {
    return series.map((item: any) => {
      return { value: item.id, label: item.data_title }
    })
  }
  // 客户编码
  if (value == 'customer_number' && customerList) {
    return customerList.map((item: any) => {
      return { value: item.customer_number, label: item.customer_number }
    })
  }
  // 客户名称
  if (value == 'product_name' && productList) {
    return productList.map((item: any) => {
      return { value: item.product_name, label: item.product_name }
    })
  }
  // 产品编码
  if (value == 'product_number' && productList) {
    return productList.map((item: any) => {
      return { value: item.product_number, label: item.product_number }
    })
  }
  // 产品名称
  if (value == 'customer_name' && customerList) {
    return customerList.map((item: any) => {
      return { value: item.customer_name, label: item.customer_name }
    })
  }
  return []
}

export const CustomSearch = [
  { label: '客户编码', prop: 'customer_number', type: 'lazySelect', multiple: true, apiType: 1 },
  { label: '客户名称', prop: 'customer_name', type: 'lazySelect', multiple: true, apiType: 1 },
  { label: '产品名称', prop: 'product_name', type: 'lazySelect', multiple: false, apiType: 2 },
  { label: '产品编码', prop: 'product_number', type: 'autocomplete', multiple: false, apiType: 2 },
  { label: '品牌', prop: 'assistant_id', type: 'select', multiple: true },
  { label: '系列', prop: 'xl_id', type: 'select', multiple: true },
  { label: '物料大类', prop: 'large_category_id', type: 'select', multiple: true },
]
export const CustomCloums = [
  { label: '客户名称', prop: 'customer_name', width: '240' },
  { label: '客户编码', prop: 'customer_number', width: '120', type: '' },
  { label: '产品编码', prop: 'product_number', width: '120' },
  { label: '产品名称', prop: 'product_name' },
  { label: '品牌', prop: 'brand', width: '100' },
  { label: '条码', prop: 'barcode', width: '140' },
  { label: '规格型号', prop: 'specification', width: '100', type: '' },
  { label: '基本单位', prop: 'unit', width: '100', type: '' },
  { label: '系列', prop: 'xl_name', width: '140', type: '' },
  { label: '物料大类', prop: 'large_category', width: '100' },
  { label: '所属价目表', prop: 'price_list_name', width: '160', type: 'custom' },
]

/**
 * 产品-客户-销售组织映射
 */
export const MappingSearch = [
  { label: '品牌', prop: 'assistant_id', type: 'select' },
  { label: '条码', prop: 'barcode', type: 'select' },
  { label: '品名', prop: 'name', type: 'select' },
  { label: '下单/收款组织', prop: 'org_id', type: 'select' },
  { label: '客户分组', prop: 'group_id', type: 'select' },
]
export const MappingCloums = [
  { label: '品牌', prop: 'assistant_name', width: 120 },
  { label: '条码', prop: 'barcode' },
  { label: '品名', prop: 'name', },
  { label: '下单/收款组织', prop: 'org_name', },
  { label: '备注', prop: 'note', },
  { label: '客户分组', prop: 'group_name' },
]

/* 客户可售产品 */
export const occupySalesSearch = [
  { label: '客户编码', prop: 'customer_number', type: 'lazySelect', multiple: true, apiType: 1 },
  { label: '客户名称', prop: 'customer_name', type: 'lazySelect', multiple: true, apiType: 1 },
]
export const occupySalesCloums = [
  { label: '客户名称', prop: 'customer_name', },
  { label: '客户编码', prop: 'customer_number', },
  { label: '更新时间', prop: 'updated_at', },
]
/* 客户可售产品 */
export const occupySalesPreviewSearch = [
  { label: '产品名称', prop: 'product_name', type: 'lazySelect', multiple: false, apiType: 2 },
  { label: '产品编码', prop: 'product_number', type: 'autocomplete', multiple: false, apiType: 2 },
  { label: '品牌', prop: 'assistant_id', type: 'select', multiple: true },
  { label: '系列', prop: 'xl_id', type: 'select', multiple: true },
  { label: '物料大类', prop: 'large_category_id', type: 'select', multiple: true },
]
export const occupySalesPreviewCloums = [
  { label: '客户名称', prop: 'customer_name', width: '240' },
  { label: '客户编码', prop: 'customer_number', width: '120', type: '' },
  { label: '产品编码', prop: 'product_number', width: '120' },
  { label: '产品名称', prop: 'product_name' },
  { label: '品牌', prop: 'brand', width: '100' },
  { label: '条码', prop: 'barcode', width: '140' },
  { label: '规格型号', prop: 'specification', width: '100', type: '' },
  { label: '基本单位', prop: 'unit', width: '100', type: '' },
  { label: '系列', prop: 'xl_name', width: '140', type: '' },
  { label: '物料大类', prop: 'large_category', width: '100' },
  { label: '所属价目表', prop: 'price_list_name', width: '160', type: 'custom' },
]
